import request from '@/utils/request';
import type { RouteRecordNormalized } from 'vue-router';
import { UserState } from '@/store/modules/user/types';
import type { ResponseBody } from './typing';

export interface LoginData {
  account: string;
  password: string;
}

export function login(data: LoginData) {
  return request.post<ResponseBody>('/auth/login', data);
}

export function logout() {
  return request.post<ResponseBody>('/auth/logout');
}

export function getUserInfo() {
  return request.get<UserState>('/auth/me');
}

export function updatePasswordApi(data: any) {
  return request.post<ResponseBody>('/auth/password', data);
}

export function getMenuList() {
  return request.post<RouteRecordNormalized[]>('/auth/menu');
}
